(function e(t,r){if(typeof exports==="object"&&exports&&typeof exports.nodeName!=="string"){r(exports)}else if(typeof define==="function"&&define.amd){define(["exports"],r)}else{t.Mustache={};r(t.Mustache)}})(this,function e(t){var r=Object.prototype.toString;var n=Array.isArray||function e(t){return r.call(t)==="[object Array]"};function i(e){return typeof e==="function"}function s(e){return n(e)?"array":typeof e}function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(e,t){return e!=null&&typeof e==="object"&&t in e}var u=RegExp.prototype.test;function l(e,t){return u.call(e,t)}var f=/\S/;function c(e){return!l(f,e)}var p={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function h(e){return String(e).replace(/[&<>"'`=\/]/g,function e(t){return p[t]})}var v=/\s*/;var d=/\s+/;var g=/\s*=/;var w=/\s*\}/;var y=/#|\^|\/|>|\{|&|=|!/;function x(e,r){if(!e)return[];var i=[];var s=[];var o=[];var u=false;var l=false;function f(){if(u&&!l){while(o.length)delete s[o.pop()]}else{o=[]}u=false;l=false}var p,h,x;function E(e){if(typeof e==="string")e=e.split(d,2);if(!n(e)||e.length!==2)throw new Error("Invalid tags: "+e);p=new RegExp(a(e[0])+"\\s*");h=new RegExp("\\s*"+a(e[1]));x=new RegExp("\\s*"+a("}"+e[1]))}E(r||t.tags);var U=new m(e);var T,j,S,V,C,A;while(!U.eos()){T=U.pos;S=U.scanUntil(p);if(S){for(var I=0,R=S.length;I<R;++I){V=S.charAt(I);if(c(V)){o.push(s.length)}else{l=true}s.push(["text",V,T,T+1]);T+=1;if(V==="\n")f()}}if(!U.scan(p))break;u=true;j=U.scan(y)||"name";U.scan(v);if(j==="="){S=U.scanUntil(g);U.scan(g);U.scanUntil(h)}else if(j==="{"){S=U.scanUntil(x);U.scan(w);U.scanUntil(h);j="&"}else{S=U.scanUntil(h)}if(!U.scan(h))throw new Error("Unclosed tag at "+U.pos);C=[j,S,T,U.pos];s.push(C);if(j==="#"||j==="^"){i.push(C)}else if(j==="/"){A=i.pop();if(!A)throw new Error('Unopened section "'+S+'" at '+T);if(A[1]!==S)throw new Error('Unclosed section "'+A[1]+'" at '+T)}else if(j==="name"||j==="{"||j==="&"){l=true}else if(j==="="){E(S)}}A=i.pop();if(A)throw new Error('Unclosed section "'+A[1]+'" at '+U.pos);return b(k(s))}function k(e){var t=[];var r,n;for(var i=0,s=e.length;i<s;++i){r=e[i];if(r){if(r[0]==="text"&&n&&n[0]==="text"){n[1]+=r[1];n[3]=r[3]}else{t.push(r);n=r}}}return t}function b(e){var t=[];var r=t;var n=[];var i,s;for(var a=0,o=e.length;a<o;++a){i=e[a];switch(i[0]){case"#":case"^":r.push(i);n.push(i);r=i[4]=[];break;case"/":s=n.pop();s[5]=i[2];r=n.length>0?n[n.length-1][4]:t;break;default:r.push(i)}}return t}function m(e){this.string=e;this.tail=e;this.pos=0}m.prototype.eos=function e(){return this.tail===""};m.prototype.scan=function e(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var n=r[0];this.tail=this.tail.substring(n.length);this.pos+=n.length;return n};m.prototype.scanUntil=function e(t){var r=this.tail.search(t),n;switch(r){case-1:n=this.tail;this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,r);this.tail=this.tail.substring(r)}this.pos+=n.length;return n};function E(e,t){this.view=e;this.cache={".":this.view};this.parent=t}E.prototype.push=function e(t){return new E(t,this)};E.prototype.lookup=function e(t){var r=this.cache;var n;if(r.hasOwnProperty(t)){n=r[t]}else{var s=this,a,u,l=false;while(s){if(t.indexOf(".")>0){n=s.view;a=t.split(".");u=0;while(n!=null&&u<a.length){if(u===a.length-1)l=o(n,a[u]);n=n[a[u++]]}}else{n=s.view[t];l=o(s.view,t)}if(l)break;s=s.parent}r[t]=n}if(i(n))n=n.call(this.view);return n};function U(){this.cache={}}U.prototype.clearCache=function e(){this.cache={}};U.prototype.parse=function e(r,n){var i=this.cache;var s=i[r];if(s==null)s=i[r+":"+(n||t.tags).join(":")]=x(r,n);return s};U.prototype.render=function e(t,r,n){var i=this.parse(t);var s=r instanceof E?r:new E(r);return this.renderTokens(i,s,n,t)};U.prototype.renderTokens=function e(t,r,n,i){var s="";var a,o,u;for(var l=0,f=t.length;l<f;++l){u=undefined;a=t[l];o=a[0];if(o==="#")u=this.renderSection(a,r,n,i);else if(o==="^")u=this.renderInverted(a,r,n,i);else if(o===">")u=this.renderPartial(a,r,n,i);else if(o==="&")u=this.unescapedValue(a,r);else if(o==="name")u=this.escapedValue(a,r);else if(o==="text")u=this.rawValue(a);if(u!==undefined)s+=u}return s};U.prototype.renderSection=function e(t,r,s,a){var o=this;var u="";var l=r.lookup(t[1]);function f(e){return o.render(e,r,s)}if(!l)return;if(n(l)){for(var c=0,p=l.length;c<p;++c){u+=this.renderTokens(t[4],r.push(l[c]),s,a)}}else if(typeof l==="object"||typeof l==="string"||typeof l==="number"){u+=this.renderTokens(t[4],r.push(l),s,a)}else if(i(l)){if(typeof a!=="string")throw new Error("Cannot use higher-order sections without the original template");l=l.call(r.view,a.slice(t[3],t[5]),f);if(l!=null)u+=l}else{u+=this.renderTokens(t[4],r,s,a)}return u};U.prototype.renderInverted=function e(t,r,i,s){var a=r.lookup(t[1]);if(!a||n(a)&&a.length===0)return this.renderTokens(t[4],r,i,s)};U.prototype.renderPartial=function e(t,r,n){if(!n)return;var s=i(n)?n(t[1]):n[t[1]];if(s!=null)return this.renderTokens(this.parse(s),r,n,s)};U.prototype.unescapedValue=function e(t,r){var n=r.lookup(t[1]);if(n!=null)return n};U.prototype.escapedValue=function e(r,n){var i=n.lookup(r[1]);if(i!=null)return t.escape(i)};U.prototype.rawValue=function e(t){return t[1]};t.name="mustache.js";t.version="2.3.0";t.tags=["{{","}}"];var T=new U;t.clearCache=function e(){return T.clearCache()};t.parse=function e(t,r){return T.parse(t,r)};t.render=function e(t,r,n){if(typeof t!=="string"){throw new TypeError('Invalid template! Template should be a "string" '+'but "'+s(t)+'" was given as the first '+"argument for mustache#render(template, view, partials)")}return T.render(t,r,n)};t.to_html=function e(r,n,s,a){var o=t.render(r,n,s);if(i(a)){a(o)}else{return o}};t.escape=h;t.Scanner=m;t.Context=E;t.Writer=U;return t});